import 'package:flutter/cupertino.dart';
import 'package:flutter_base/common/fun.dart';

///路由跳转,入栈
goTo(
  BuildContext context,
  Widget page, {
  Callback<dynamic>? onPageResult,
}) async {
  dynamic res = await Navigator.push(
    context,
    CupertinoPageRoute(builder: (context) => page),
  );

  if (onPageResult != null) {
    onPageResult(res);
  }
}

///路由跳转,替换
goToReplace(BuildContext context, Widget page) async {
  Navigator.pushReplacement(
    context,
    CupertinoPageRoute(builder: (context) => page),
  );
}

///路由跳转,并清空栈内所有页面
goToReplaceAll(BuildContext context, Widget page) async {
  Navigator.pushAndRemoveUntil(
      context, CupertinoPageRoute(builder: (crx) => page), (route) => false);
}
